home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Programming / OUI / rcs / cstring.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  20.9 KB  |  764 lines

  1. head    1.4;
  2. access;
  3. symbols;
  4. locks
  5.     dlorre:1.4; strict;
  6. comment    @// @;
  7.  
  8.  
  9. 1.4
  10. date    98.04.08.15.09.56;    author dlorre;    state Exp;
  11. branches;
  12. next    1.3;
  13.  
  14. 1.3
  15. date    97.07.14.04.20.28;    author dlorre;    state Exp;
  16. branches;
  17. next    1.2;
  18.  
  19. 1.2
  20. date    96.08.28.19.58.57;    author dlorre;    state Exp;
  21. branches;
  22. next    1.1;
  23.  
  24. 1.1
  25. date    96.08.22.02.05.10;    author dlorre;    state Exp;
  26. branches;
  27. next    ;
  28.  
  29.  
  30. desc
  31. @Oui.lib -- Object User Interface
  32. Projet créé en 1994
  33. Auteur: Dominique Lorre
  34. @
  35.  
  36.  
  37. 1.4
  38. log
  39. @size adjusted
  40. @
  41. text
  42. @// $Id: cstring.cc 1.3 1997/07/14 04:20:28 dlorre Exp $
  43. #include <graphics/gfxmacros.h>
  44. #include <intuition/intuition.h>
  45. #include <intuition/classes.h>
  46. #include <intuition/classusr.h>
  47. #include <intuition/imageclass.h>
  48. #include <intuition/gadgetclass.h>
  49. #include <intuition/icclass.h>
  50. #include <intuition/cghooks.h>
  51. #include <libraries/gadtools.h>
  52.  
  53. #include <string.h>
  54. #include <stdio.h>
  55. #include <mydebug.h>
  56.  
  57. #include "screen.h"
  58. #include "window.h"
  59. #include "gadgets/cstring.h"
  60. #include "gadgets/eclass.h"
  61. #include "gadgetlist.h"
  62.  
  63. #include <proto/exec.h>
  64. #include <proto/graphics.h>
  65. #include <proto/intuition.h>
  66. #include <proto/utility.h>
  67. #include <clib/alib_protos.h>
  68. #include <compiler.h>
  69.  
  70. Class *BOOPSIELabel ;
  71. int InitELabel(void) ;
  72. void FreeELabel(void) ;
  73.  
  74. extern "C" STDARGS ULONG HookEntry() ;
  75.  
  76. // ========================================================================
  77. // ==========================  CSTRING CLASS ==============================
  78. // ========================================================================
  79.  
  80.  
  81. cstring::cstring(gadgetlist *gl,
  82.                  void (window::*func)(gadget *, unsigned long, unsigned short),
  83.                  const char *t,
  84.                  const char *text,
  85.                  long border, long place, char style) : gadget(gl, func)
  86. {
  87. int i, l1, l2 ;
  88. BOOL underset = FALSE ;
  89. UWORD *pens = gl->win->ws->drawinfo->dri_Pens;
  90. short gleft, gtop, gwidth, gheight ;
  91.  
  92.     gl->ng->ng_Flags = place ;
  93.     InitELabel() ;
  94.  
  95.     gleft = gl->ng->ng_LeftEdge ;
  96.     gtop = gl->ng->ng_TopEdge ;
  97.     gwidth = gl->ng->ng_Width ;
  98.     gheight = gl->ng->ng_Height ;
  99.  
  100.     if (style & BOTTOMCSTRING)
  101.         gtop = short(-gtop) ;
  102.     if (style & RIGHTCSTRING)
  103.         gleft = short(-gleft) ;
  104.     if (style & WIDTHCSTRING)
  105.         gwidth = short(-gwidth) ;
  106.     if (style & HEIGHTCSTRING)
  107.         gheight = short(-gheight) ;
  108.  
  109.  
  110.     if (t) {
  111.  
  112.         it1 = new IntuiText ;
  113.         it2 = new IntuiText ;
  114.         it3 = new IntuiText ;
  115.  
  116.         plain = new TTextAttr ;
  117.         underline = new TTextAttr ;
  118.  
  119.         it1->FrontPen = it2->FrontPen = it3->FrontPen = gl->win->ws->drawinfo->dri_Pens[(place&NG_HIGHLABEL)?HIGHLIGHTTEXTPEN:TEXTPEN] ;
  120.         it1->BackPen = it2->BackPen = it3->BackPen = 0 ;
  121.         it1->DrawMode = it2->DrawMode = it3->DrawMode = JAM1 ;
  122.  
  123.         norm1 = new char[strlen(t)+1] ;
  124.         norm2 = new char[strlen(t)+1] ;
  125.         under = new char[2] ;
  126.  
  127.         underkey(t) ;
  128.  
  129.         CopyMem(gl->win->ws->scr->Font, plain, sizeof(struct TTextAttr)) ;
  130.         CopyMem(gl->win->ws->scr->Font, underline, sizeof(struct TTextAttr)) ;
  131.         underline->tta_Style |= FSF_UNDERLINED ;
  132.         font = OpenFont((TextAttr *)underline) ;
  133.  
  134.         for (i=l1=l2=0; t[i]; i++) {
  135.             if (t[i] == '_') {
  136.                 if (t[i+1]) under[0] = t[++i] ;
  137.                 underset = TRUE ;
  138.             }
  139.             else {
  140.                 if (underset) {
  141.                     norm2[l2++] = t[i] ;
  142.                 }
  143.                 else {
  144.                     norm1[l1++] = t[i] ;
  145.                 }
  146.             }
  147.         }
  148.         norm1[l1] = '\0' ;
  149.         norm2[l2] = '\0' ;
  150.         under[1] = '\0' ;
  151.  
  152.         if (l1) {
  153.             it1->IText = (UBYTE *)norm1 ;
  154.             it1->ITextFont = (TextAttr *)plain ;
  155.             if (underset) {
  156.                 it1->NextText = it2 ;
  157.                 it2->LeftEdge = short(IntuiTextLength(it1)) ;
  158.                 it2->IText = (UBYTE *)under ;
  159.                 it2->ITextFont = (TextAttr *)underline ;
  160.                 if (l2) {
  161.                     it2->NextText = it3 ;
  162.                     it3->LeftEdge = short(it2->LeftEdge + IntuiTextLength(it2)) ;
  163.                     it3->IText = (UBYTE *)norm2 ;
  164.                     it3->ITextFont = (TextAttr *)plain ;
  165.                 }
  166.             }
  167.         }
  168.         else if (underset) {
  169.             it1->IText = (UBYTE *)under ;
  170.             it1->ITextFont = (TextAttr *)underline ;
  171.             it1->NextText = it2 ;
  172.             it2->LeftEdge = short(IntuiTextLength(it1)) ;
  173.             it2->IText = (UBYTE *)norm2 ;
  174.             it2->ITextFont = (TextAttr *)plain ;
  175.         }
  176.     }
  177.     gad = gl->gad = (Gadget *)NewObject(BOOPSIELabel, NULL,
  178.             GA_ID,          id,
  179.             GA_Top,         gtop,
  180.             GA_Left,        gleft,
  181.             GA_Width,       gwidth,
  182.             GA_Height,      gheight,
  183.  
  184.             (style & BOTTOMCSTRING)?GA_RelBottom:TAG_IGNORE,   TRUE,
  185.             (style & RIGHTCSTRING)?GA_RelRight:TAG_IGNORE,     TRUE,
  186.             (style & WIDTHCSTRING)?GA_RelWidth:TAG_IGNORE,     TRUE,
  187.             (style & HEIGHTCSTRING)?GA_RelHeight:TAG_IGNORE,   TRUE,
  188.  
  189.             GA_Previous,    gl->gad,
  190.             GA_IntuiText,   it1 ,
  191.             GA_Border,      border,
  192.             GA_Text,        text,
  193.             EGA_Flags,      place,
  194.             EGA_TextAttr,   gl->ng->ng_TextAttr,
  195.             EGA_XPens,      gl->win->ws->xpens,
  196.             EGA_GPen,       gl->gpen,
  197.  
  198.             TAG_END) ;
  199. }
  200.  
  201. cstring::~cstring()
  202. {
  203.     if (norm1) delete norm1 ;
  204.     if (norm2) delete norm2 ;
  205.     if (under) delete under ;
  206.  
  207.     if (it1) delete it1 ;
  208.     if (it2) delete it2 ;
  209.     if (it3) delete it3 ;
  210.  
  211.     if (plain) delete plain ;
  212.     if (underline) delete underline ;
  213.  
  214.     if (gad) DisposeObject(gad) ;
  215.     if (font) CloseFont(font) ;
  216.     FreeELabel() ;
  217. }
  218.  
  219. void cstring::set(const char *text)
  220. {
  221.     SetGadgetAttrs((Gadget *)gad, w, NULL,
  222.         GA_Text,    text,
  223.         TAG_END) ;
  224. }
  225.  
  226. void cstring::keystroke(BOOL shifted)
  227. {
  228.     if (gfunc)
  229.         gadget::action(NULL, 0) ;
  230.     else
  231.         glist->selectgadget(id+1, shifted) ;
  232. }
  233.  
  234.  
  235. // ========================================================================
  236. // =============================== ELabel =================================
  237. // ========================================================================
  238.  
  239. struct ELabelINST {
  240.     IntuiText   *IText ;
  241.     TextFont    *TFont ;
  242.     STRPTR      Text ;
  243.     LONG        Val ;
  244.     LONG        Flags ;
  245.     BOOL        Border ;
  246.     UWORD       *XPens ;
  247.     UWORD       GPen ;
  248.     WORD        LeftEdge ;
  249.     WORD        TopEdge ;
  250.     WORD        Width ;
  251.     WORD        Height ;
  252.     BOOL        Drawable ;
  253.     BOOL        IsNum ;
  254.     BOOL        DrawAll ;
  255. } ;
  256.  
  257. static ULONG STDARGS dispatchELabel(Class *cl, Object *o, Msg msg);
  258. static ULONG   RenderELabel(Class *, Gadget *, gpRender *) ;
  259.  
  260. void  SetLims(ELabelINST *inst, Gadget *g, GadgetInfo *gi) ;
  261. static unsigned short ditherData[2] = {0x5555,0xAAAA};
  262.  
  263. static int ELabelCnt = 0 ;
  264. int InitELabel(void)
  265. {
  266.     if (ELabelCnt) {
  267.         ELabelCnt++ ;
  268.     }
  269.     else if (!(BOOPSIELabel = MakeClass(NULL, (UBYTE *)GADGETCLASS, NULL,
  270.         sizeof(ELabelINST), 0))) {
  271.         ELabelCnt = 0 ;
  272.     }
  273.     else {
  274.         BOOPSIELabel->cl_Dispatcher.h_Entry = (HOOKFUNC)HookEntry ;
  275.         BOOPSIELabel->cl_Dispatcher.h_SubEntry = (HOOKFUNC)dispatchELabel;
  276.         ELabelCnt = 1 ;
  277.     }
  278.     return ELabelCnt ;
  279. }
  280.  
  281. void FreeELabel(void)
  282. {
  283.     ELabelCnt-- ;
  284.     if (!ELabelCnt)
  285.         FreeClass(BOOPSIELabel) ;
  286. }
  287.  
  288. ULONG SAVEDS STDARGS dispatchELabel(  Class *cl, Object *o, Msg msg)
  289. {
  290. ELabelINST  *inst ;
  291. ULONG       retval = FALSE ;
  292. Object      *object ;
  293. TTextAttr   *ta ;
  294.  
  295.     GETA4 ;
  296.     switch (msg->MethodID) {
  297.     case OM_NEW:
  298.         if (object = (Object *)DoSuperMethodA(cl, o, msg)) {
  299.             Gadget *g = (Gadget *)object ;
  300.             inst = (ELabelINST *)INST_DATA(cl, object) ;
  301.             inst->IText = (IntuiText *)GetTagData(GA_IntuiText,
  302.                 NULL,
  303.                 ((opSet *)msg)->ops_AttrList) ;
  304.             inst->Flags = (LONG)GetTagData(EGA_Flags, PLACETEXT_LEFT,
  305.                     ((opSet *)msg)->ops_AttrList) ;
  306.             inst->Text = (STRPTR)GetTagData(GA_Text, NULL,
  307.                     ((opSet *)msg)->ops_AttrList) ;
  308.             inst->Border = (BOOL)GetTagData(GA_Border, FALSE,
  309.                     ((opSet *)msg)->ops_AttrList) ;
  310.             inst->XPens = (UWORD *)GetTagData(EGA_XPens, NULL,
  311.                     ((opSet *)msg)->ops_AttrList) ;
  312.  
  313.             inst->GPen = (UWORD)GetTagData(EGA_GPen, NULL,
  314.                     ((opSet *)msg)->ops_AttrList) ;
  315.  
  316.             inst->IsNum = BOOL(FindTagItem(EGA_Number,
  317.                                      ((opSet *)msg)->ops_AttrList) != NULL) ;
  318.             if (inst->IsNum)
  319.                 inst->Val = (LONG)GetTagData(EGA_Number, NULL,
  320.                     ((opSet *)msg)->ops_AttrList) ;
  321.  
  322.             inst->DrawAll = TRUE ;
  323.  
  324.             if (g->Flags & GFLG_RELRIGHT)
  325.                 g->LeftEdge = (short)GetTagData(GA_Left, g->LeftEdge, ((opSet *)msg)->ops_AttrList) ;
  326.             if (g->Flags & GFLG_RELHEIGHT)
  327.                 g->Height = (short)GetTagData(GA_Height, g->Height, ((opSet *)msg)->ops_AttrList) ;
  328.             if (g->Flags & GFLG_RELWIDTH)
  329.                 g->Width = (short)GetTagData(GA_Width, g->Width, ((opSet *)msg)->ops_AttrList) ;
  330.             if (g->Flags & GFLG_RELBOTTOM)
  331.                 g->TopEdge = (short)GetTagData(GA_Top, g->TopEdge, ((opSet *)msg)->ops_AttrList) ;
  332.  
  333.             ta = (TTextAttr *)GetTagData(EGA_TextAttr, NULL,
  334.                     ((opSet *)msg)->ops_AttrList) ;
  335.  
  336.             if (ta) {
  337.                 inst->TFont = OpenFont((TextAttr *)ta) ;
  338.             }
  339.             retval = (ULONG)object ;
  340.         }
  341.         break ;
  342.     case OM_DISPOSE:
  343.         inst = (ELabelINST *)INST_DATA(cl, o) ;
  344.         if (inst->TFont) CloseFont(inst->TFont) ;
  345.         retval = DoSuperMethodA(cl, o, msg) ;
  346.         break ;
  347.     case OM_SET:
  348.         retval = DoSuperMethodA(cl, o, msg) ;
  349.         if ( FindTagItem(GA_Text, ((opSet *)msg)->ops_AttrList) ||
  350.              FindTagItem(EGA_Number, ((opSet *)msg)->ops_AttrList) ) {
  351.             RastPort *rp ;
  352.             Gadget *g  = (Gadget *)o ;
  353.  
  354.             inst = (ELabelINST *)INST_DATA(cl, o) ;
  355.             inst->Text = (STRPTR)GetTagData(GA_Text, (ULONG)inst->Text, ((opSet *)msg)->ops_AttrList) ;
  356.             inst->Val = (LONG)GetTagData(EGA_Number, (ULONG)inst->Val, ((opSet *)msg)->ops_AttrList) ;
  357.             inst->DrawAll = FALSE ;
  358.  
  359.             if (rp = ObtainGIRPort( ((opSet *)msg)->ops_GInfo) ) {
  360.  
  361.                 DoMethod(o, GM_RENDER, ((opSet *)msg)->ops_GInfo, rp, GREDRAW_REDRAW) ;
  362.                 ReleaseGIRPort(rp) ;
  363.             }
  364.             inst->DrawAll = TRUE ;
  365.         }
  366.         break ;
  367.     case GM_RENDER:
  368.         retval = RenderELabel(cl, (Gadget *)o, (gpRender *)msg) ;
  369.         break ;
  370.     default :
  371.         retval = DoSuperMethodA(cl, o, msg) ;
  372.         break ;
  373.     }
  374.     return retval ;
  375. }
  376.  
  377.  
  378. ULONG SAVEDS RenderELabel(Class *cl, Gadget *g, gpRender *msg)
  379. {
  380. RastPort            *rp ;       // RastPort où le gadget est affiché
  381. ULONG               retval ;    // Code de retour
  382. UWORD               *pens ;     // pinceaux de l'écran
  383. UWORD               tpen ;      // couleur du texte
  384. ELabelINST          *inst ;     // pointeur sur les données
  385. IntuiText           *itext ;    // affichage du label
  386. LONG                l, t, len ; // left, top, len utilisés pour l'affichage
  387. struct TextExtent   te ;        // Calcul de la largeur du texte
  388.  
  389.  
  390.     GETA4 ;
  391.     // Initialisations
  392.  
  393.     // Affectation du RastPort selon la méthode d'appel
  394.  
  395.     if (msg->MethodID == GM_RENDER)
  396.         rp = msg->gpr_RPort ;
  397.     else
  398.         rp = ObtainGIRPort(msg->gpr_GInfo) ;
  399.  
  400.     if (rp) {
  401.  
  402.         retval = TRUE ;
  403.         pens = msg->gpr_GInfo->gi_DrInfo->dri_Pens ;
  404.         inst = (ELabelINST *)INST_DATA(cl, (Object *)g) ;
  405.  
  406.         tpen = inst->GPen ;
  407.         WaitTOF() ;
  408.         if (inst->DrawAll) {
  409.             EraseRect(rp, inst->LeftEdge, inst->TopEdge,
  410.                 inst->LeftEdge+inst->Width-1, inst->TopEdge+inst->Height-1) ;
  411.         }
  412.         else {
  413.             SetAPen(rp, (inst->Border)?inst->XPens[GFILL_PEN]:pens[BACKGROUNDPEN]) ;
  414.             RectFill(rp, inst->LeftEdge+2, inst->TopEdge+2,
  415.                 inst->LeftEdge+inst->Width-3, inst->TopEdge+inst->Height-3) ;
  416.         }
  417.         SetLims(inst, g, msg->gpr_GInfo) ;  // Calcul des limites
  418.         if (!inst->Drawable) {
  419.             retval = FALSE ;
  420.             goto out ;
  421.         }
  422.  
  423.         SetDrMd(rp, JAM2) ;
  424.         SetAPen(rp, pens[TEXTPEN]) ;
  425.         SetBPen(rp, (inst->Border)?inst->XPens[GFILL_PEN]:pens[BACKGROUNDPEN]) ;
  426.  
  427.         if (inst->Border && inst->DrawAll) {
  428.             SetAPen(rp, inst->XPens[GFILL_PEN]) ;
  429.             RectFill(rp, inst->LeftEdge+1, inst->TopEdge+1,
  430.                 inst->LeftEdge+inst->Width-2, inst->TopEdge+inst->Height-2) ;
  431.  
  432.             SetAPen(rp, pens[SHINEPEN]) ;
  433.  
  434.             Move(rp, inst->LeftEdge+1, inst->TopEdge+inst->Height-1) ;
  435.             Draw(rp, inst->LeftEdge+1, inst->TopEdge+1) ;
  436.             Draw(rp, inst->LeftEdge+inst->Width-1, inst->TopEdge+1) ;
  437.             Draw(rp, inst->LeftEdge+inst->Width-1, inst->TopEdge+inst->Height-1) ;
  438.             Draw(rp, inst->LeftEdge, inst->TopEdge+inst->Height-1) ;
  439.  
  440.             SetAPen(rp, pens[SHADOWPEN]) ;
  441.  
  442.             Move(rp, inst->LeftEdge, inst->TopEdge) ;
  443.             Draw(rp, inst->LeftEdge+inst->Width-2, inst->TopEdge) ;
  444.             Draw(rp, inst->LeftEdge+inst->Width-2, inst->TopEdge+inst->Height-2) ;
  445.             Draw(rp, inst->LeftEdge, inst->TopEdge+inst->Height-2) ;
  446.             Draw(rp, inst->LeftEdge, inst->TopEdge) ;
  447.         }
  448.  
  449.  
  450.         if (inst->IText) {  // Le gagdet possède un label
  451.             itext = inst->IText ;
  452.  
  453.             // recherche du dernier itext pour la longueur
  454.  
  455.             while (itext->NextText) itext = itext->NextText ;
  456.  
  457.             // Le calcul par défaut est pour PLACETEXT_IN
  458.  
  459.             len = IntuiTextLength(itext) + itext->LeftEdge ;
  460.             t = inst->TopEdge + 1 +
  461.                 (inst->Height - itext->ITextFont->ta_YSize -2) / 2 ;
  462.             l = inst->LeftEdge + 1 + (inst->Width - len - 2) / 2 ;
  463.  
  464.  
  465.             if (inst->Flags & PLACETEXT_RIGHT) {
  466.                 l = inst->LeftEdge + inst->Width + 4 ;
  467.             }
  468.             else if (inst->Flags & PLACETEXT_ABOVE) {
  469.                 t = inst->TopEdge - itext->ITextFont->ta_YSize - 4 ;
  470.             }
  471.             else if (inst->Flags & PLACETEXT_BELOW) {
  472.                 t = inst->TopEdge + inst->Height + 4 ;
  473.             }
  474.             else if (!(inst->Flags & PLACETEXT_IN)) {  // PLACETEXT_LEFT
  475.                 l = inst->LeftEdge - len - 4 ;
  476.             }
  477.             PrintIText(rp, inst->IText, l, t) ;
  478.         }
  479.         if (inst->IsNum) {
  480.         char text[20] ;
  481.             sprintf(text, "%ld", inst->Val) ;
  482.             SetAPen(rp, tpen) ; // Couleur du pinceau
  483.  
  484.             if (inst->TFont) SetFont(rp, inst->TFont) ;
  485.  
  486.  
  487.             len = (long)TextFit(rp, text,
  488.                 strlen(text), &te, NULL, 1,
  489.                  inst->Width-4, inst->Height-2) ;
  490.  
  491.  
  492.             l = inst->LeftEdge + (inst->Width - te.te_Width) / 2 ;
  493.             t = inst->TopEdge + (inst->Height -
  494.                     te.te_Extent.MinY - te.te_Extent.MaxY) / 2 ;
  495.  
  496.             Move(rp, l, t) ;
  497.             Text(rp, text, len) ;
  498.         }
  499.         else if (inst->Text) {   // Le gadget contient un texte
  500.  
  501.             SetAPen(rp, tpen) ; // Couleur du pinceau
  502.  
  503.             if (inst->TFont) SetFont(rp, inst->TFont) ;
  504.  
  505.             len = (long)TextFit(rp, inst->Text,
  506.                 strlen(inst->Text), &te, NULL, 1,
  507.                  inst->Width-4, inst->Height-2) ;
  508.  
  509.             if (inst->Width > te.te_Width)
  510.                 l = inst->LeftEdge + (inst->Width - te.te_Width) / 2 ;
  511.             else
  512.                 l = inst->LeftEdge+2 ;
  513.             t = inst->TopEdge + (inst->Height -
  514.                     te.te_Extent.MinY - te.te_Extent.MaxY) / 2 ;
  515.  
  516.             Move(rp, l, t) ;
  517.             Text(rp, inst->Text, len) ;
  518.         }
  519. out:
  520.         if (msg->MethodID != GM_RENDER)
  521.             ReleaseGIRPort(rp) ;
  522.     }
  523.     else
  524.         retval = FALSE ;
  525.     return retval ;
  526. }
  527.  
  528.  
  529. void SAVEDS SetLims(ELabelINST *inst, Gadget *g, GadgetInfo *gi)
  530. {
  531. long GLeft, GTop, GWidth, GHeight ;
  532.  
  533.     GETA4 ;
  534.     GLeft = g->LeftEdge ;
  535.     GTop = g->TopEdge ;
  536.     GWidth = g->Width  ;
  537.     GHeight = g->Height ;
  538.  
  539.     if (g->Flags & GFLG_RELRIGHT) {
  540.         GLeft = gi->gi_Window->Width - 1 ;
  541.         GLeft += g->LeftEdge ;
  542.     }
  543.  
  544.     if (g->Flags & GFLG_RELHEIGHT) {
  545.         GHeight = gi->gi_Window->Height ;
  546.         GHeight += g->Height ;
  547.     }
  548.  
  549.     if (g->Flags & GFLG_RELBOTTOM) {
  550.         GTop = gi->gi_Window->Height - 1 ;
  551.         GTop += g->TopEdge ;
  552.     }
  553.  
  554.     if (g->Flags & GFLG_RELWIDTH) {
  555.         GWidth = gi->gi_Window->Width ;
  556.         GWidth += g->Width ;
  557.     }
  558.     inst->Drawable = BOOL(GLeft >= 0 && GTop >= 0 &&
  559.         GWidth > 4 &&
  560.         GHeight > 4) ;
  561.     if (inst->Drawable) {
  562.         inst->LeftEdge = GLeft ;
  563.         inst->TopEdge = GTop ;
  564.         inst->Width = GWidth ;
  565.         inst->Height = GHeight ;
  566.     }
  567.  
  568. }
  569. @
  570.  
  571.  
  572. 1.3
  573. log
  574. @*** empty log message ***
  575. @
  576. text
  577. @d1 1
  578. a1 1
  579. // $Id: cstring.cc 1.2 1996/08/28 19:58:57 dlorre Exp dlorre $
  580. d468 4
  581. a471 1
  582.             l = inst->LeftEdge + (inst->Width - te.te_Width) / 2 ;
  583. @
  584.  
  585.  
  586. 1.2
  587. log
  588. @changement look + ajout support pour cnumber
  589. @
  590. text
  591. @d1 1
  592. a1 1
  593. // $Id$
  594. d14 1
  595. d22 6
  596. a27 18
  597. #include <cxxproto/graphics.h>
  598. #include <cxxproto/intuition.h>
  599. #include <cclib/alib_protos.h>
  600.  
  601. extern "C" {
  602.  
  603. extern struct ExecBase *SysBase ;
  604. void CopyMem( APTR source, APTR dest, unsigned long size );
  605. #pragma libcall SysBase CopyMem 270 09803
  606.  
  607. extern struct Library *UtilityBase ;
  608. struct TagItem *FindTagItem( Tag tagVal, struct TagItem *tagList );
  609. ULONG GetTagData( Tag tagValue, unsigned long defaultVal,
  610.         struct TagItem *tagList );
  611. #include <pragmas/utility_pragmas.h>
  612.  
  613. void kprintf(STRPTR format, ...) ;
  614. }
  615. d33 2
  616. d42 2
  617. a43 2
  618.                  STRPTR t,
  619.                  STRPTR text,
  620. d88 2
  621. a89 2
  622.         CopyMem(gl->win->ws->screen->Font, plain, sizeof(struct TTextAttr)) ;
  623.         CopyMem(gl->win->ws->screen->Font, underline, sizeof(struct TTextAttr)) ;
  624. d112 1
  625. a112 1
  626.             it1->IText = norm1 ;
  627. d117 1
  628. a117 1
  629.                 it2->IText = under ;
  630. d122 1
  631. a122 1
  632.                     it3->IText = norm2 ;
  633. d128 1
  634. a128 1
  635.             it1->IText = under ;
  636. d132 1
  637. a132 1
  638.             it2->IText = norm2 ;
  639. a147 1
  640.  
  641. d178 1
  642. a178 1
  643. void cstring::set(STRPTR text)
  644. d200 1
  645. a200 1
  646.     TextFont    *TextFont ;
  647. d213 1
  648. d216 2
  649. a217 2
  650. static ULONG __asm dispatchELabel(register __a0 Class *cl,
  651.     register __a2 Object *o, register __a1 Msg msg);
  652. a218 1
  653. static ULONG   RenderELabel(Class *, Gadget *, gpRender *) ;
  654. d228 1
  655. a228 1
  656.     else if (!(BOOPSIELabel = MakeClass(NULL, GADGETCLASS, NULL,
  657. d233 2
  658. a234 1
  659.         BOOPSIELabel->cl_Dispatcher.h_Entry = (HOOKFUNC)dispatchELabel;
  660. d247 1
  661. a247 3
  662. ULONG __saveds __asm dispatchELabel(   register __a0 Class *cl,
  663.                                         register __a2 Object *o,
  664.                                         register __a1 Msg msg)
  665. d254 1
  666. d281 2
  667. d296 1
  668. a296 1
  669.                 inst->TextFont = OpenFont((TextAttr *)ta) ;
  670. d303 1
  671. a303 1
  672.         if (inst->TextFont) CloseFont(inst->TextFont) ;
  673. d316 1
  674. d323 1
  675. d337 1
  676. a337 1
  677. ULONG __saveds RenderELabel(Class *cl, Gadget *g, gpRender *msg)
  678. d349 1
  679. a351 1
  680.  
  681. a365 1
  682.  
  683. d367 9
  684. a375 2
  685.  
  686.         EraseRect(rp, inst->LeftEdge, inst->TopEdge, inst->LeftEdge+inst->Width-1, inst->TopEdge+inst->Height-1) ;
  687. d386 1
  688. a386 1
  689.         if (inst->Border) {
  690. d389 1
  691. a389 1
  692.                 inst->LeftEdge+inst->Width-1, inst->TopEdge+inst->Height-1) ;
  693. d395 3
  694. a397 3
  695.             Draw(rp, inst->LeftEdge+inst->Width, inst->TopEdge+1) ;
  696.             Draw(rp, inst->LeftEdge+inst->Width, inst->TopEdge+inst->Height) ;
  697.             Draw(rp, inst->LeftEdge, inst->TopEdge+inst->Height) ;
  698. d402 3
  699. a404 3
  700.             Draw(rp, inst->LeftEdge+inst->Width-1, inst->TopEdge) ;
  701.             Draw(rp, inst->LeftEdge+inst->Width-1, inst->TopEdge+inst->Height-1) ;
  702.             Draw(rp, inst->LeftEdge, inst->TopEdge+inst->Height-1) ;
  703. d443 1
  704. a443 1
  705.             if (inst->TextFont) SetFont(rp, inst->TextFont) ;
  706. d462 1
  707. a462 2
  708.             if (inst->TextFont) SetFont(rp, inst->TextFont) ;
  709.  
  710. a467 1
  711.  
  712. d485 1
  713. a485 1
  714. void __saveds SetLims(ELabelINST *inst, Gadget *g, GadgetInfo *gi)
  715. d489 1
  716. d496 1
  717. a496 1
  718.         GLeft = gi->gi_Window->Width ;
  719. d506 1
  720. a506 1
  721.         GTop = gi->gi_Window->Height ;
  722. @
  723.  
  724.  
  725. 1.1
  726. log
  727. @Initial revision
  728. @
  729. text
  730. @d1 1
  731. d40 3
  732. a42 3
  733. static Class *BOOPSIELabel ;
  734. static int InitELabel(void) ;
  735. static void FreeELabel(void) ;
  736. d212 1
  737. d222 1
  738. d285 6
  739. d316 2
  740. a317 1
  741.         if ( FindTagItem(GA_Text, ((opSet *)msg)->ops_AttrList)) {
  742. d323 1
  743. d393 5
  744. a397 3
  745.             Move(rp, inst->LeftEdge, inst->TopEdge+inst->Height-1) ;
  746.             Draw(rp, inst->LeftEdge+inst->Width-1, inst->TopEdge+inst->Height-1) ;
  747.             Draw(rp, inst->LeftEdge+inst->Width-1, inst->TopEdge) ;
  748. d399 1
  749. a399 1
  750.             SetAPen(rp, pens[TEXTPEN]) ;
  751. d401 5
  752. a405 5
  753.             Move(rp, inst->LeftEdge+1, inst->TopEdge+1) ;
  754.             Draw(rp, inst->LeftEdge+1, inst->TopEdge+inst->Height-2) ;
  755.             Draw(rp, inst->LeftEdge+inst->Width-2, inst->TopEdge+inst->Height-2) ;
  756.             Draw(rp, inst->LeftEdge+inst->Width-2, inst->TopEdge+1) ;
  757.             Draw(rp, inst->LeftEdge+1, inst->TopEdge+1) ;
  758. d438 21
  759. a458 1
  760.         if (inst->Text) {   // Le gadget contient un texte
  761. a489 1
  762. long KWidth, KHeight ;
  763. @
  764.